package com.liug.droidsmall2.study.designmode;

/**
 * build模式
 * Created by LG on 2018/8/20.
 */

public class BuildMode {
    private int icon;
    private String title;
    private String message;
    private boolean isCancel;

    //使用
    public void use() {
        BuildMode.Buidler buidler = new BuildMode.Buidler();
        buidler.setIcon(1)
                .setCancel(true)
                .setMessage("build模式")
                .setTitle("标题")
                .builder();
    }


    private BuildMode(Buidler buidler) {
        this.icon = buidler.icon;
        this.title = buidler.title;
        this.message = buidler.message;
        this.isCancel = buidler.isCancel;
    }

    public int getIcon() {
        return icon;
    }

    public void setIcon(int icon) {
        this.icon = icon;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public boolean isCancel() {
        return isCancel;
    }

    public void setCancel(boolean cancel) {
        isCancel = cancel;
    }

    static class Buidler {

        private int icon;
        private String title;
        private String message;
        private boolean isCancel;

        public int getIcon() {
            return icon;
        }

        public Buidler setIcon(int icon) {
            this.icon = icon;
            return this;
        }

        public String getTitle() {
            return title;
        }

        public Buidler setTitle(String title) {
            this.title = title;
            return this;
        }

        public String getMessage() {
            return message;
        }

        public Buidler setMessage(String message) {
            this.message = message;
            return this;
        }

        public boolean isCancel() {
            return isCancel;
        }

        public Buidler setCancel(boolean cancel) {
            isCancel = cancel;
            return this;
        }

        public BuildMode builder() {

            return new BuildMode(this);
        }
    }
}
